﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebNext.UI.Utils
{
	public class CaptchaConfiguration
	{
		public int A
		{
			get;
			private set;
		}

		public int B
		{
			get;
			private set;
		}

		public string CaptchaKey
		{
			get;
			private set;
		}

		public CaptchaConfiguration(int a, int b, string captchaKey)
		{
			this.A = a;
			this.B = b;
			this.CaptchaKey = captchaKey;
		}
	}

	public class CaptchaHelper
	{
		public static CaptchaConfiguration CreateCaptcha(HttpContextBase httpContext)
		{
			Random random = new Random();
			int a = random.Next(10);
			int b = random.Next(10);

			string captchaKey = Guid.NewGuid().ToString();
			httpContext.Session[captchaKey] = a + b;

			return new CaptchaConfiguration(a, b, captchaKey);
		}
	}
}